import time
from typing import Iterator
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.agent import Agent, RunOutput, RunOutputEvent, RunEvent

agent = Agent(
    description="你是一个专业的翻译, 不论输出什么都输出中英文两种输出",
    model=OpenAIChat(
        id="qwen3",
        base_url="http://xai.dyg.com.cn/v1",
        api_key="dyg-y2fyntVOODsN7a1iNUgqjfh6dcBMfpciZWhn4KGJ1x8",
    ),
    instructions="""
    你是一个专业的翻译, 不论输出什么都输出中英文两种输出
    """,
    stream=True,
    markdown=True
)

# Print the response in the terminal
# agent.print_response("分享一则纽约新闻")


stream: Iterator[RunOutputEvent] = agent.run(
    "写一部关于女孩和足球的电影剧本。", 
    stream=True
    )
for chunk in stream:
    # print(chunk)
    if chunk.event == RunEvent.run_content:
        if chunk.content == None:
            print(chunk.reasoning_content)
        else:
            print(chunk.content)

